package io.scnb.lesson002.demo18.test3;

import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.config.Scope;

/**
 * @see MyScope 作用域的实现
 */

public class BeanMyScope implements Scope {

    public static final String SCOPE_MY = "my";

    /**
     * 自定义作用域会自动调用这个get方法来创建bean对象
     * @param name
     * @param objectFactory
     * @return
     */
    @Override
    public Object get(String name, ObjectFactory<?> objectFactory) {
        System.out.println("BeanMyScope >>>>>>>>> get:" + name); 
        // 获取bean实例返回
        return objectFactory.getObject(); 
    }

    @Override
    public Object remove(String name) {
        return null;
    }

    @Override
    public void registerDestructionCallback(String name, Runnable callback) {

    }

    @Override
    public Object resolveContextualObject(String key) {
        return null;
    }

    @Override
    public String getConversationId() {
        return null;
    }
}
